import Highcharts from 'highcharts';

export default {
  vueThis: null,
  numChart: null,
  chartsData: {},
  init(options) {
    this.vueThis = options.self;
    this.chartsData = options.data;
    // 生成图表
    this.chartAction();
  },
  chartAction() {
    const self = this;
    const selfVue = this.vueThis;
    this.numChart = new Highcharts.Chart('numChart', {
      chart: {
        type: 'column'
      },
      credits: {
        enabled: false
      },
      legend: {
        enabled: false
      },
      colors: ['#C62734'],
      xAxis: {
        className: 'highcharts-color-name',
        categories: ['ETH', 'TRON', 'COSMOS', 'Polkadot'],
        title: {
          text: selfVue.$t('tronActivity.voteResult'),
          align: 'middle',
          y: 10,
          x: -20
        }
      },
      title: {
        text: ''
      },
      yAxis: {
        title: {
          text: `${selfVue.$t('tronActivity.Percentage')} (%)`,
        },
      },
      plotOptions: {
        column: {
          pointWidth: 30,
          colorByPoint: true,
          dataLabels: {
            enabled: true,
            format: '{point.y:.1f}%'
          }
        },
      },
      tooltip: {
        enabled: false,
        // pointFormatter() {
        //   console.log(self.series.name)
        //   return '{series.name}: <b>{point.y:.1f}%</b><br/>'
        // }
      },
      series: [{
        name: '',
        data: self.chartsData
      }],
    })
  }
}
